/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package objects;

import java.util.LinkedList;
import OBJ_Loader.Object;
/**
 *
 * @author Marcin
 */
public class Estate {
    public float sx,ex,sz,ez;
    public float res;
    public LinkedList<Object> list = new LinkedList<>();
    public SRect rect = new SRect();
    
    public Estate(float stx,float stz,float edx,float edz,float nres){
        rect.set(stx+2f, edx, stz+3f, edz+1f);
        sx=stx;ex=edx;sz=stz;ez=edz;float xr=res=nres,zr=nres;
        float hx = Math.abs(edx-stx)/res;
        float hz = Math.abs(edz-stz)/res;
        if(stx>edx) xr=-xr;
        if(stz>edz) zr=-zr;
        for(int i=0;i<=hx;i++){
            for(int j=0;j<=hz;j++){
                Object h1 = new Object("obj/house.obj",sx+i*xr,0,sz+j*zr);
                h1.setScale(0.2f);
                list.add(h1);
            }
        }
    }
    
    public float get(int i){
        switch(i){
            case 0: return sx;
            case 1: return ex;
            case 2: return sz;
            case 3: return ez;
        }       
        return 0;
    }
    public SRect getRect(){
        return rect;
    }
    public void setRot(float rot){
        for(Object o:list){
            o.setRotateY(rot);
        }
    }
    
    public void draw(){
        for(Object o:list){
            o.draw();
        }
    }
}
